package com.andy.beef.ui.main.api

import com.andy.module.BASE_BREED
import com.andy.module.BASE_TRADE
import com.andy.module.BASE_WAGY
import com.andy.beef.ui.main.bean.*
import com.andy.module.network.*
import retrofit2.http.FieldMap
import retrofit2.http.FormUrlEncoded
import retrofit2.http.POST
import retrofit2.http.Url

/**
 * @creator:LuoFan
 * @date:2022/5/27
 * @description:
 */

//双重校验锁式-单例 封装NetApiService 方便直接快速调用简单的接口
val mainService: MainApiService by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
    RetrofitClient.getService(MainApiService::class.java, SimpleApiService.SERVER_URL)
}

interface MainApiService : SimpleApiService {

    companion object {
        //牧场牛只数量分类统计
        const val URL_CATTLE_QTY = BASE_BREED + "mobile/statistics/cattle-qty"

        //牧场牛只平均日增重统计
        const val URL_WEIGHT_GROWTH = BASE_BREED + "mobile/statistics/weight-growth"

        //牧场牛只平均饲喂成本统计
        const val URL_FEED_PRICE = BASE_BREED + "mobile/statistics/feed-price"

        //交易数据
        const val URL_TRADE_DATA = BASE_TRADE + "mobile/cattle/trade/trade-data-statistics"

        //TMR统计
        const val URL_TMR_STATISTICS = BASE_BREED + "mobile/tmrFeedRecord/statistics"

        //服务网点分页列表
        const val URL_SERVICE_POINT_LIST = BASE_WAGY + "mobile/service-point/list"

        //当前用户的服务网点列表
        const val URL_CHOOSE_SERVICE_POINT_LIST = BASE_WAGY + "mobile/service-point/permission-list"
    }

    /**
     * 牧场牛只数量分类统计
     */
    @FormUrlEncoded
    @POST
    suspend fun getCattleQty(@Url url: String, @FieldMap params: HashMap<String, Any>): ApiResponse<CattleQtyBean>


    /**
     * 牧场牛只平均日增重统计
     */
    @FormUrlEncoded
    @POST
    suspend fun getWeightGrowth(@Url url: String, @FieldMap params: HashMap<String, Any>): ApiResponse<WeightGrowthBean>

    /**
     * 牧场牛只平均饲喂成本统计
     */
    @FormUrlEncoded
    @POST
    suspend fun getFeedPrice(@Url url: String, @FieldMap params: HashMap<String, Any>): ApiResponse<FeedPriceBean>

    /**
     * 交易数据
     */
    @FormUrlEncoded
    @POST
    suspend fun getTradeData(@Url url: String, @FieldMap params: HashMap<String, Any>): ApiResponse<TradeDataBean>

    /**
     * TMR统计
     */
    @FormUrlEncoded
    @POST
    suspend fun getTmrSummary(@Url url: String, @FieldMap params: HashMap<String, Any>): ApiResponse<TmrSummaryBean>

    /**
     * 获取服务网点
     */
    @FormUrlEncoded
    @POST
    suspend fun getServicePointList(
        @Url url: String,
        @FieldMap params: HashMap<String, Any>
    ): ApiResponse<ApiPagerResponse<ServicePointBean>>
}